﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;

namespace WCS.Infrastructure.EFCore;

/// <summary>
/// 账户交易记录表
/// </summary>
[Table("AccountTransaction")]
[Index("UserId", Name = "idx_AccountTransaction_UserId")]
[Index("TransactionNo", Name = "idx_TransactionNo", IsUnique = true)]
public partial class AccountTransaction
{
    /// <summary>
    /// 账户交易记录ID
    /// </summary>
    [Key]
    [StringLength(32)]
    public string Id { get; set; } = null!;

    /// <summary>
    /// 账户交易编号
    /// </summary>
    [StringLength(32)]
    public string TransactionNo { get; set; } = null!;

    /// <summary>
    /// 关联用户ID
    /// </summary>
    [StringLength(32)]
    public string? UserId { get; set; }

    /// <summary>
    /// 变动金额（正数=增加，负数=减少）
    /// </summary>
    public long Amount { get; set; }

    /// <summary>
    /// 变动后余额
    /// </summary>
    public long BalanceAfter { get; set; }

    /// <summary>
    /// 账户交易记录类型：1=分账收入,2=订单退款,3=余额提现,4=结算转入可提现,5=手动转账,6=优惠券互推,10=订单手续费,11=提现手续费,12=优惠券服务费
    /// </summary>
    public int TransactionType { get; set; }

    /// <summary>
    /// 交易时间
    /// </summary>
    [Column(TypeName = "timestamp(6) without time zone")]
    public DateTime TransactionTime { get; set; }

    /// <summary>
    /// 交易备注（如：退款冻结，结算T+1）
    /// </summary>
    [StringLength(255)]
    public string? Remark { get; set; }

    /// <summary>
    /// 变动的余额类型(1=可用余额,2=冻结余额,3=可提现余额,4=未结算余额,5=待分账余额)
    /// </summary>
    public int? BalanceType { get; set; }

    /// <summary>
    /// 订单ID
    /// </summary>
    [StringLength(32)]
    public string? OrderId { get; set; }

    /// <summary>
    /// 分账记录详情ID
    /// </summary>
    [StringLength(32)]
    public string? DividedRecordDetailId { get; set; }

    /// <summary>
    /// 扩展属性
    /// </summary>
    public string? ExtraProperties { get; set; }

    /// <summary>
    /// 提现记录ID
    /// </summary>
    [StringLength(32)]
    public string? WithdrawalRecordId { get; set; }

    /// <summary>
    /// 支付平台ID
    /// </summary>
    [StringLength(32)]
    public string? PaymentPlatformId { get; set; }
}
